var app = getApp()
Page({
  data: {
    id:2,
    list: [],
    title:'',
    hidden:false,
    subject_id:''
  },
  onLoad: function(options) {
    var that = this;
    wx.setNavigationBarTitle({
      title:options.title
    });

    that.setData({ title:options.title,subject_id:options.subject_id,id:options.id });
    wx.request({
        url: app.globalData.domain+'/wx/index.php',
        method:'POST',
        data: {title: options.title,'type': 'list' },
        header: {'Content-Type': 'application/x-www-form-urlencoded'},
        success: function(res) {
            that.setData({ list:res.data,hidden: !that.data.hidden });
        }
    });
  },
  widgetsToggle: function (e) {
    var id = e.currentTarget.id, list = this.data.list;
    for (var i = 0, len = list.length; i < len; ++i) {
      if (list[i].id == id) {
        list[i].open = !list[i].open;
      } else {
        list[i].open = false;
      }
    }
    this.setData({
      list: list
    });
  },
  showSuggest:function(){
     wx.navigateTo({
       url: '../suggest/suggest'
    })   
  },
  onShareAppMessage: function () {
    return {
      title: this.data.title,
      desc: app.globalData.userInfo.nickName+'分享给你'+this.data.title+'【海风教育】',
      path: 'page/untitled/untitled?id='+ this.data.id+'&title='+ this.data.title
    }
  }
});
